
import {Children, lazy,Suspense} from 'react'
import {useRoutes} from 'react-router-dom'
import Login from "../pages/Login"
// import Reg from '../pages/Reg'
// import Index from '../pages/Index'
const Reg = lazy(() => import('../pages/Reg')) //路由懒加载
const Index = lazy(() => import('../pages/Index')) //路由懒加载
const About = lazy(() => import('../pages/About')) //路由懒加载
const News = lazy(() => import('../pages/News')) //路由懒加载
const NewsDetail = lazy(() => import('../pages/NewsDetail')) //路由懒加载
const routes=[

    {
        path: '/login',
        element: <Login></Login>,
    },
     {
        path:"/reg",
        element:<Suspense fallback={""}><Reg></Reg></Suspense>,
     },
     {
        path: '/',
        element: <Suspense fallback={<div>loading...</div>}><Index /></Suspense>,
        children:[

            {
                path:"about",
                element:<Suspense fallback={""}><About></About></Suspense>,
             },
             {
                path:"news",
                element:<Suspense fallback={""}><News /></Suspense>,
             },
             {
                path:"newsDetail/:id.html",
                element:<Suspense fallback={""}><NewsDetail /></Suspense>,
             }
            
            
        ]
    },
]

export default ()=>{

    return useRoutes(routes);
  
  }